﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ZJF.TestString
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Test11();
            Console.Read();
        }

        #region
        static void Test1()
        {
            string a = "Hello C Sharp World,别来无恙！";
            Console.WriteLine(a.Length);
        }

        static void Test2()
        {
            int sum = 0;
            for (int i = 0; i <= 100; i++)
            {
                sum += i;
            }
            Console.WriteLine(sum);
        }

        static void Test3()
        {
            double[] avgArr = new double[3];
            for (int i = 0; i < 3; i++)
            {
                double avg, total = 0;
                for (int j = 0; j < 3; j++)
                {
                    Console.WriteLine($"请输入第{j}个人的身高：");
                    double h = double.Parse(Console.ReadLine());
                    total += h;
                }
                avg = total / 3;
                Console.WriteLine($"第{i}个人的平均身高：{avg}");
                avgArr[i] = avg;
            }
            double max = 0;
            foreach (var item in avgArr)
            {
                if (item > max)
                {
                    max = item;
                }
            }
            Console.WriteLine($"身高最大值：{max}");
        }

        static void Test4()
        {
            string email = "1032141242135@qq.com";
            int a = email.IndexOf('@');
            int b = email.IndexOf("qq.com");

            Console.WriteLine($"@ index is {a}; qq.com index is {b}"); // @ index is 13; qq.com index is 14
            Console.WriteLine("+++++++++++++++++++++++++++++++++++++++");

            int c = email.Length;
            Console.WriteLine($"email len = {c}");  // email len = 20

        }

        static void Test5()
        {
            string email = "12421341@163.com";
            string number = email.Substring(0, 8);
            Console.WriteLine(number);
            Console.WriteLine("+++++++++++++++++");

            string number1 = email.Substring(0, email.IndexOf('@')); // 12421341
            Console.WriteLine(number1);

            string type = email.Substring(email.IndexOf('@') + 1);  // 163.com
            Console.WriteLine(type);
        }

        static void Test6()
        {

            string name1 = "kobe";
            string name2 = "Kobe";
            string name3 = "kobe";

            Console.WriteLine("name1==name2  " + (name1 == name2));
            Console.WriteLine("name1==name3  " + (name1 == name3));


            Console.WriteLine("name1==name2  " + name1.Equals(name2));
            Console.WriteLine("name1==name3  " + name1.Equals(name3));




        }


        static void Test7() {

            string s1 = "fsdaFFkkfdsagvgKK";
            string s1ToLower = s1.ToLower();
            string s1ToUpper = s1.ToUpper();
            Console.WriteLine(s1ToUpper);
            Console.WriteLine(s1ToLower);
        
       }

        static void Test8()
        {
            string email = "123@qq.com@163.com";
            int index = email.LastIndexOf('@');
            Console.WriteLine(index);
        }
        #endregion

        static void Test9() {
            string s1 = "";
            string s2 = string.Empty;

            Console.WriteLine("s1==s2" + (s1 == s2));

        }


        static void Test10() {
            string s1 = "AA BB CC DD";
            string[] arr = s1.Split();  // 默认使用空格分割
            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }

            string s2 = string.Join("-", arr);
            Console.WriteLine(s2);
        }


        static void Test11() {
            const double PI = 3.14;
            PI = 3.141;  // 报错
            Console.WriteLine(PI);
        }
    }
}
